using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using ibba.src.noriskbo.ViewModels;
using ibba.src.sl.recursos.MVVM;

namespace ibba.src.noriskbo
{
    public partial class PageImportacaoLote : Page
    {
        UIElement elementGrid = null;

        public PageImportacaoLote()
        {
            InitializeComponent();

            this.Title = string.Concat(AppHelper.NomeSistema, ": Importação Lote");
            this.lblSubtitulo.Text = "Selecione uma opção abaixo";

            this.Loaded += new RoutedEventHandler(PageImportacaoLote_Loaded);
        }

        void PageImportacaoLote_Loaded(object sender, RoutedEventArgs e)
        {
            //LoadContent(elementGrid);
        }

        private void LoadContent(UIElement element)
        {
            gridContent.Children.Clear();

            if (element != null)
            {
                lblSubtitulo.Text = element.ToString();
                gridContent.Children.Add(element);
            }
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string param = null;

            param = e.Uri.ToString().Substring(1).Replace("/", "_");

            App.MainPage.barraMenu.ClearButtons();
            App.MainPage.barraPesquisa.CampoPesquisaVisivel = System.Windows.Visibility.Collapsed;

            if (!string.IsNullOrEmpty(param))
            {
                if (param.Equals(Constantes.TiposImportacao.IMPORTAR_GARANTIAS, StringComparison.InvariantCultureIgnoreCase))
                    elementGrid = new views.childs.ImportarGarantias();

                else if (param.Equals(Constantes.TiposImportacao.IMPORTAR_OPERACOES, StringComparison.InvariantCultureIgnoreCase))
                    elementGrid = new views.childs.ImportarOperacoes();
                else
                    elementGrid = null;
            }

            LoadContent(elementGrid);
        }

    }

}
